package org.calculator.parser;

import java.io.InputStream;
import java.util.List;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

public class LayoutParserSax {
	private InputStream inputStream;

	public LayoutParserSax(InputStream inputStream) {
		this.inputStream = inputStream;
	}

	public List<String> parse() {
		try {
			SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
			LayoutHandler handler = new LayoutHandler();
			parser.parse(inputStream, handler);
			return handler.getButtons();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}